package com.zy.explore.license.application.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.explore.license.domain.mybatis.dao.SysEventLogDao;
import com.zy.explore.license.domain.mybatis.entity.SysEventLog;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * (表sys_event_log)服务接口实现类
 *
 * @author ZY
 * @date 2021-05-09 14:52:03
 */
@EnableAsync(proxyTargetClass = true)
@Service
public class SysEventLogService extends ServiceImpl<SysEventLogDao, SysEventLog> {

    /**
     * 记录事件信息
     *
     * @param userId       用户ID
     * @param ip           ip地址
     * @param eventType    事件类型 1.登陆 2.新增 3.修改 4.删除
     * @param eventDesc    事件描述
     * @param eventContent 事件内容
     * @param eventResult  事件结果
     */
    @Async
    public void recordEvent(Integer userId, String ip, Integer eventType, String eventDesc, String eventContent, String eventResult) {
        baseMapper.insert(SysEventLog.builder()
                .userId(userId)
                .ip(ip)
                .eventType(eventType)
                .eventDesc(eventDesc)
                .eventContent(eventContent)
                .eventResult(eventResult)
                .createTime(new Date())
                .delFlag(0)
                .build());
    }

}